import 'package:flutter/material.dart';
import './layout/CardPage.dart';
import './layout/ContainerPage.dart';
import './layout/GridViewPage.dart';
import './layout/ListViewPage.dart';
import './layout/StackPage.dart';

///
/// Flutter常用布局测试
/// 
/// 来源@url https://www.jianshu.com/p/fccb4c43c268
///
class LayoutTest extends StatefulWidget {
  @override
  _LayoutTestState createState() => _LayoutTestState();
}

class _LayoutTestState extends State<LayoutTest> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('常用布局测试'),
      ),
      body: new ListView(
          children: <Widget>[
            _createListTile('Card', context, new CardPage()),
            _createListTile('Container', context, new ContainerPage()),
            _createListTile('GridView', context, new GridViewPage()),
            _createListTile('ListView', context, new ListViewPage()),
            _createListTile('Stack', context, new StackPage()),
          ],
        ),
    );
  }

  Widget _createListTile(String title, BuildContext context, Widget page) {
    return new ListTile(
      title: new Text(title),
      onTap: (){
        Navigator.of(context).push(new MaterialPageRoute(builder: (BuildContext context) => page));
      },
    );
  }
}